<?php
header('content-type:text/html;charset=utf8');
//接收前端传过了的数据
$username=$_POST['username'];
$password=$_POST['password'];
$conn = mysqli_connect('localhost','root','root','xiaomi');
$sql = "SELECT * FROM `user` WHERE `username`='$username' AND `password`='$password'";
$res = mysqli_query($conn,$sql);
$row = mysqli_fetch_assoc($res);
mysqli_close($conn);
if($row){
    //如果登陆成功
    $arr=[
        "meta"=>[
            "status"=>0,
            "msg"=>"登录成功"
        ],
        "data"=>null
    ];
    
}else{
    $arr=[
        "meta"=>[
            "status"=>1,
            "msg"=>"登录失败"
        ],
        "data"=>null
    ];
}
echo json_encode($arr);
?>